extends layout

block headContent
	title Next Halving

block content
	+pageTitle("Next Halving")


	+dismissableInfoAlert("nextHavlingNoteDismissed", "About Next Halving...")
		h6.mb-2 About Next Halving

		| This page shows details about the next halving. Halvings occur every #{nextHalvingData.halvingBlockInterval.toLocaleString()} blocks and cut the block subsidy (new supply creation) in half. So far #{nextHalvingData.halvingCount.toLocaleString()} halving#{halvingCount == 1 ? " has" : "s have"} occurred. After #{nextHalvingData.terminalHalvingCount} halvings, the block subsidy will drop to zero and no more halvings will occur.

	if (nextHalvingData.nextHalvingIndex > -1)
		+contentSection("Summary")
			+summaryRow(3)
				+summaryItem("Halving Number")
					| #{nextHalvingData.nextHalvingIndex.toLocaleString()}

				+summaryItem("Block Height", "The block height at which the new block subsidy will begin.")
					| #{nextHalvingData.nextHalvingBlock.toLocaleString()}

				+summaryItem("Subsidy", "The new supply that will be created (and rewarded to the winning miner) for each new block during the next halving's era.")
					- let subsidy = coinConfig.blockRewardFunction(nextHalvingData.nextHalvingBlock, global.activeBlockchain);
					+valueDisplay(subsidy)

		+contentSection("Timeline / Progress")
			+summaryRow(2)
				+summaryItem("Blocks Remaining")
					| #{nextHalvingData.blocksUntilNextHalving.toLocaleString()}

				+summaryItem("Date (Estimated)", "The date is estimated based on the number of blocks remaining and the current mining rate (up until the next difficulty adjustment).")
					+timestamp(nextHalvingData.nextHalvingDate.getTime() / 1000)

			- let progressPercent = new Decimal(nextHalvingData.halvingBlockInterval).minus(nextHalvingData.blocksUntilNextHalving).dividedBy(nextHalvingData.halvingBlockInterval).times(100);
			.progress.mt-5(role="progressbar", aria-label="Next halving progress", aria-valuenow=progressPercent.toDP(0), aria-valuemin="0", aria-valuemax="100")
				.progress-bar(style=`width: ${progressPercent.toDP(0)}%`)
					| #{progressPercent.toDP(1)}%


	else
		.alert.alert-success All halvings are done.
			if (global.activeBlockchain == "main")
				span.ms-2 May humanity enjoy the Bitcoin Renaissance.


	
	//pre #{JSON.stringify(nextHalvingData, null, 4)}